package com.demo.singleton;

/**
 * @Author: shubin_yao
 * @Date: 2022/05/10/21:37
 * @Description: 内部类实现单例模式(推荐)
 * 优点: 线程安全
 * 无加锁性能瓶颈
 */
public class Singleton_04 {
    private static class SingletonHolder {
        private static Singleton_04 instance = new Singleton_04();
    }

    private Singleton_04() {
        System.out.println("=======内部类实现单例模式(推荐),构造方法Singleton_04");
    }

    public static Singleton_04 getInstance() {
        return SingletonHolder.instance;
    }

}
